import 'package:basic_common/app_theme.dart';
import 'package:basic_common/common_exports.dart';
import 'package:basic_widgets/app_bar_widget.dart';
import 'package:flutter/gestures.dart';

import 'authinfo_controller.dart';
import 'view/auth_authen_view.dart';
import 'view/auth_identity_view.dart';
import 'view/auth_realname_view.dart';


class AuthInfoPage extends GetView<AuthInfoController> {
  const AuthInfoPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: backAppbar(title: "认证资料"),
      body: Column(
        children: [
          buildTitleItem(),
          SizedBox(
            height: ScreenHelper.height(10),
          ),
          Expanded(
            child: Container(
              padding: EdgeInsets.symmetric(horizontal: ScreenHelper.width(15)),
              child: Obx(() => TabBarView(
                  controller: controller.tabController,
                  children: controller.titleList.map<Widget>((e) {
                    if (controller.type.value == 0) {
                      return AuthRealNameView();
                    }
                    if (controller.type.value == 1) {
                      return AuthIdentityView();
                    }
                    if (controller.type == 2) {
                      return AuthAuthenView();
                    }
                    return AuthRealNameView();
                  }).toList())),
            ),
          )
        ],
      ),
    );
  }

  /// 标题
  Widget buildTitleItem() {
    return Container(
      color: Colors.white,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Expanded(
            child: SizedBox(
              height: 48,
              child: TabBar(
                  controller: controller.tabController,
                  indicatorSize: TabBarIndicatorSize.label,
                  labelPadding: EdgeInsets.zero,
                  padding: EdgeInsets.zero,
                  indicatorWeight: 1,
                  dragStartBehavior: DragStartBehavior.down,
                  indicatorColor: AppTheme.primyColor,
                  labelColor: AppTheme.dartTextColor,
                  labelStyle: TextStyle(
                      color: AppTheme.dartTextColor,
                      fontSize: ScreenHelper.sp(16)),
                  unselectedLabelColor: AppTheme.weakTextColor,
                  tabs: controller.titleList
                      .map<Widget>((item) => Align(
                            alignment: Alignment.center,
                            child: Tab(
                              text: item["attr"],
                            ),
                          ))
                      .toList()),
            ),
          ),
        ],
      ),
    );
  }
}
